package ar.com.mindset.geometrics_wi.colorScheme;

import ar.com.mindset.geometrics_wi.colorScheme.Legend.LegendType;
import ar.com.mindset.geometrics_wi.colorScheme.divisionStrategy.DivisionStrategy;
import ar.com.mindset.geometrics_wi.colorScheme.divisionStrategy.LinealDivision;
import ar.com.mindset.geometrics_wi.colorScheme.divisionStrategy.ManualDivision;

/**
 * @author http://www.mindset-designs.com
 */
public class ContinuousColorScheme extends WithLegendColorScheme {

    private String name;
    private DivisionStrategy divisionStrategy;


    public LinealDivision useLinealDivisionStrategy() {
        this.divisionStrategy = new LinealDivision();
        return (LinealDivision) this.divisionStrategy;
    }

    public ManualDivision useManualDivisionStrategy() {
        this.divisionStrategy = new ManualDivision();
        return (ManualDivision) this.divisionStrategy;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void useBarLegend() {
        this.legend = new Legend(LegendType.BAR_LEGEND);
    }

    public void useContinuousListLegend() {
        this.legend = new Legend(LegendType.CONTINUOUS_LIST_LEGEND);
    }

    public void useContinuousListLegend(int squareSize) {
        this.useContinuousListLegend();
        this.legend.setSquareSize(squareSize);
    }

    @Override
    protected void writeColorScheme(StringBuffer xml) {
        xml.append("<continuous");
        if (this.name != null) {
            xml.append(" name='").append(this.name).append("'");
        }
        xml.append(">");

        if (this.legend != null) {
            this.legend.write(xml);
        }

        if (divisionStrategy != null) {
            this.divisionStrategy.write(xml);
        }

        xml.append("</continuous>");
    }
}
